#ifndef _PIN_CTRL_H_
#define _PIN_CTRL_H_

#define ADDR_REG 0x41000104
#define DATA_REG 0x41000100

#define PIN_MUX_CTRL_REG0_OFFSET 0x00
#define PIN_MUX_CTRL_REG1_OFFSET 0x04
#define PIN_MUX_CTRL_REG2_OFFSET 0x08
#define PIN_MUX_CTRL_REG3_OFFSET 0x0C
#define PIN_MUX_CTRL_REG4_OFFSET 0x10
#define PIN_MUX_CTRL_REG5_OFFSET 0x14
#define PIN_MUX_CTRL_REG6_OFFSET 0x18

/*chip totally has 68 pins, 44 pins among them can be configured by pin mux regs*/

/*pin mux reg0 cfg*/
#define PWM_UNISOUND             (2 <<  0) //pin48: PWM play
#define GPIO1                    (0 <<  3) //pin49: default
#define I2S1_BLCK                (1 <<  6) //pin50: I2S1 play
#define GPIO16                   (0 <<  9) //pin52: default
#define GPIO4                    (0 << 12) //pin51: default
#define UART1_TX                 (1 << 15) //pin58: UART1_TX
#define UART1_RX                 (1 << 18) //pin57: UART1_RX
#define GPIO7                    (0 << 21) //pin56: default
#define GPIO8                    (0 << 24) //pin55: default
#define I2C0_SCL                 (1 << 27) //pin46: I2C0_SCL to ES7243E/ES8218E 

/*pin mux reg1 cfg*/
#define I2C0_SDA                 (1 <<  0) //pin47: I2C0_SCL to ES7243E/ES8218E
#define UART0_TX                 (0 <<  3) //pin54: UART0_TX
#define UART0_RX                 (0 <<  6) //pin53: UART0_RX
#define GPIO13                   (0 <<  9) //pin66: default
#define GPIO14                   (0 << 12) //pin67: default
#define GPIO15                   (0 << 15) //pin68: default
#define SD_CMD                   (1 << 18) //pin1:  SD_CMD
#define GPIO17                   (0 << 21) //pin64: default
#define GPIO18                   (0 << 24) //pin65: default
#define GPIO19                   (3 << 27) //pin16: GPIO19

/*pin mux reg2 cfg*/
#define GPIO20                   (3 << 0)  //pin20: GPIO20
#define GPIO21                   (3 << 3)  //pin19: GPIO21
#define GPIO22                   (3 << 6)  //pin18: GPIO22
#define GPIO23                   (3 << 9)  //pin17: GPIO23
#define GPIO29                   (3 << 12) //pin15: GPIO29
#define I2S0_MCLK                (3 << 15) //pin43: record clk
#define I2S0_SDI1                (3 << 18) //pin39: MIC(record)
#define PDM_CLK                  (2 << 21) //pin38: digital MIC
#define PDM_D0                   (2 << 24) //pin37: digital MIC
#define I2S0_SDI0                (3 << 27) //pin42: AEC(record)

/*pin mux reg3 cfg*/
#define I2S0_LRCK                (3 << 0)  //pin40: record clk
#define I2S0_BCLK                (3 << 3)  //pin41: record clk
#define GPIO31                   (3 << 6)  //pin36: GPIO31
#define GPIO26                   (0 << 9)  //pin26: default
#define SPI_CLK                  (2 << 12) //pin2:  SD card
#define SPI_TX                   (2 << 15) //pin4:  SD card
#define UART2_RX                 (0 << 18) //pin14: default
#define GPIO11                   (0 << 21) //pin13: default
#define SPI_RX                   (2 << 24) //pin12: SD card
#define GPIO12                   (0 << 27) //pin59: default

/*pin mux reg4 cfg, only bit6 ~ bit9 valid*/
#define GPIO2                    (0 << 6)  //pin60: default
#define GPIO3                    (0 << 9)  //pin62: default

/*pin mux reg5 cfg, only bit6 ~ bit9 valid*/
#define UART3_RX                 (2 << 6)  //pin10: UART3_RX
#define UART3_TX                 (2 << 9)  //pin11: UART3_TX


void cpu_pin_func_initialize(void);

#endif
